package zero.tech.games.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import com.alibaba.fastjson.JSONObject;

import zero.tech.games.entity.games.UserRole;
import zero.tech.redis.cache.RedisUtil;

@Component
public class UserRoleUtil {
	@Autowired
	private RedisUtil redisUtil;
	public UserRole getUserRole(int uid) {
		UserRole userRole=null;
		String str=(String) redisUtil.hget(RedisConsts.A_USERROLE, String.valueOf(uid));
		Assert.notNull(str,"此处角色缓存不为null");
		userRole=JSONObject.parseObject(str,UserRole.class);
		return userRole;
	}

}
